import { http } from '@/utils/http'

/** 查询菜单列表 */
export const listMenu = (params?: object) => {
  return http.request<HttpTreeResponse<Array<any>>>('get', '/system/menu/list', {
    params,
  })
}

/** 查询菜单详细 */
export const getMenu = (menuId: number) => {
  return http.request<HttpResponse<Object>>('get', '/system/menu/' + menuId)
}

/** 查询菜单下拉树结构 */
export const treeselect = (params?: object) => {
  return http.request<HttpResponse<Object>>('get', '/system/menu/treeselect', {
    params,
  })
}

/** 根据角色ID查询菜单下拉树结构 */
export const roleMenuTreeselect = (roleId: string) => {
  return http.request<HttpResponse<Object>>('get', '/system/menu/roleMenuTreeselect/' + roleId)
}

/** 根据当前OSType查询菜单下拉树结构 */
export const roleMenuTreeselectByOSType = (roleId: string, osTypes: any) => {
  return http.request<HttpResponse<Object>>(
    'get',
    `/system/menu/roleMenuTreeselect/${roleId}/${osTypes.join(',')}`
  )
}

/** 新增菜单 */
export const addMenu = (data?: object) => {
  return http.request<HttpResponse<Object>>('post', '/system/menu', {
    data,
  })
}

/** 修改菜单 */
export const updateMenu = (data?: object) => {
  return http.request<HttpResponse<Object>>('put', '/system/menu', {
    data,
  })
}

/** 删除菜单 */
export const delMenu = (menuId?: string) => {
  return http.request<HttpResponse<Object>>('delete', '/system/menu/' + menuId)
}
